#ifndef DW_MATHS_POLYNOMIAL_H
#	define DW_MATHS_POLYNOMIAL_H

#include "maths/utils.h"

namespace dw {
	namespace maths {

template< uint32 Degree >
struct Polynomial
{
};

// Solver for ax + b = 0
template<>
struct Polynomial< 1 >
{
public : //! @name Construction & Destruction
	//! @{
	Polynomial();
	//! @}

public : //! @name Commands
	//! @{
	uint32 solve(float32& x);
	//! @}

public : //! @name Data
	//! @{
	float32 a;
	float32 b;
	//! @}
};

// Solver for ax^2 + bx + c = 0
template<>
struct Polynomial< 2 >
{
public : //! @name Constants
	//! @{
	static const float32 DiscriminantEspilon;
	//! @}

public : //! @name Construction & Destruction
	//! @{
	Polynomial();
	//! @}

public : //! @name Commands
	//! @{
	uint32 solve(float32& x0, float32& x1);
	//! @}

public : //! @name Data
	//! @{
	float32 a;
	float32 b;
	float32 c;
	//! @}
};

// Solver for ax^3 + bx^2 + cx + d = 0
template<>
struct Polynomial< 3 >
{
public : //! @name Construction & Destruction
	//! @{
	Polynomial();
	//! @}

public : //! @name Commands
	//! @{
	uint32 solve(float32& x0, float32& x1, float32& x2);
	//! @}

public : //! @name Data
	//! @{
	float32 a;
	float32 b;
	float32 c;
	float32 d;
	//! @}
};

// Solver for ax^4 + bx^3 + cx^2 + dx + e = 0
template<>
struct Polynomial< 4 >
{
public : //! @name Construction & Destruction
	//! @{
	Polynomial();
	//! @}

public : //! @name Commands
	//! @{
	uint32 solve(float32& x0, float32& x1, float32& x2, float32& x3);
	//! @}

public : //! @name Data
	//! @{
	float32 a;
	float32 b;
	float32 c;
	float32 d;
	float32 e;
	//! @}
};

	} // namespace maths
} // namespace dw

#include "maths/polynomial.inl"

#endif // !DW_MATHS_POLYNOMIAL_H
